package com.example.ByteStream;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

/**
 * @author Jason
 * @PACKAGE_NAME com.example.ByteStream
 * @Description BufferedWriter缓冲流写入
 * @date 2023-12-13 14:03
 */
public class BufferedWriterDemo {
    public static void main(String[] args) throws IOException {
        //1.创建缓冲流
        FileWriter fw = new FileWriter("d:\\bbb.txt");
        BufferedWriter bw = new BufferedWriter(fw);

        for (int i = 0; i < 10; i++) {
            bw.write("hello" + i);
            bw.newLine();//写入一个换行符
            bw.flush();
        }

        //3.关闭
        bw.close();
    }
}
